package com.wbj.sensor

import android.location.Location
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.TextView

class LocatActivity : AppCompatActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_locat)

        val btn:Button = findViewById<Button>(R.id.btn) as Button
        val text:TextView = findViewById<TextView>(R.id.text) as TextView
        btn.setOnClickListener {
            val location: Location? =
                LocationUtils.getInstance(this@LocatActivity).showLocation()
            if (location != null) {
                val address =
                    "纬度：" + location.getLatitude().toString() + "经度：" + location.getLongitude() + "方向：" + location.getBearing()
                Log.d("FLY.LocationUtils", address)
                text.text = address
            }
        }
    }
}